package br.com.aquinoevasconcelos.servlets.cliente;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.aquinoevasconcelos.fachada.Fachada;

/**
 * Servlet implementation class RecuperarSenha
 */
@WebServlet("/RecuperarSenha")
public class RecuperarSenha extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

    public RecuperarSenha() {
        super();

    }
    
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	
    	
    	Fachada fachada = Fachada.getInstancia();
    	String email = request.getParameter("email");
    	
    	try {
    		
    		if(fachada.verificarEmailRecuperacaodeSenha(email) == true){
    			response.sendRedirect("Index?msg=senhaRecuperada");
    		}
    		else {
				response.sendRedirect("recuperar_senha.jsp?msg=erro");
			}
			
		} catch (Exception e) {
			
			response.sendRedirect("pagina_erro/erro.jsp");
		}
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		service(request, response);
	}

}
